package com.example.demo.lambda;

import org.junit.Test;

import java.util.Comparator;
import java.util.function.Consumer;

/**
 * @Description:
 * @Author: xiatian
 * @CreateTime: 2021/7/15
 * @Company: kangxu
 */
public class TestLambda2 {


    @Test
    public void test1() {
        Runnable r1 = () -> System.out.println("hello lambda");
        r1.run();
    }

    @Test
    public void test3() {
        Consumer<String> consumer = x -> System.out.println(x);
        consumer.accept("hello");
    }

    @Test
    public void test4() {
        Comparator<Integer> com = (x, y) -> {
            System.out.println("hell 函数式编程");
            return Integer.compare(x, y);
        };
    }

    @Test
    public void test5() {
        Comparator<Integer> com = (x, y) -> Integer.compare(x, y);
    }

    @Test
    public void test6() {
        System.out.println(strHander("abcdef", x -> x.toUpperCase()));
    }

    public String strHander(String str, MyFunction my) {
        return my.getValue(str);
    }

}
